<?php
class socials extends iControl{
	function init(){
	  parent::init();
	  if( !empty($this->params['section']) ) $this->pg=$this->tpl[ $this->params['section'] ];

	  $repls=array(
	    '{server}'=>urlencode('http://'.$_SERVER['SERVER_NAME']),
	    '{url}'=>urlencode('http://'.$_SERVER['SERVER_NAME'].'/'.$GLOBALS['Jlib_target']),
	    '{url_decode}'=>'http://'.$_SERVER['SERVER_NAME'].'/'.$GLOBALS['Jlib_target'],
	    '{image}'=>'',
	    '{title}'=>'',
		);
		if( !isset($this->params['clear_js_codes']) || $this->params['clear_js_codes']!='no'){
		  $rega='~<script.*</script>~isU';
    	$this->pg=preg_replace_callback($rega, 'set_scripts', $this->pg);
		}
		if( !empty($GLOBALS['Jlib_meta']['og_image']) ){
		  $img=$GLOBALS['Jlib_meta']['og_image'][ count( $GLOBALS['Jlib_meta']['og_image'] )-1 ];
			$repls['{image}']=( strpos($img, 'http://')!==false )? ($img) : ('http://'.$_SERVER['SERVER_NAME'].'/'.$img);
		}
		if( !empty($GLOBALS['Jlib_meta']['og_title']) )
			$repls['{title}']=$GLOBALS['Jlib_meta']['og_title'][0];

		$from=array_keys($repls);
	  $this->pg=str_replace($from, $repls, $this->pg);
	  //$this->pg=strjtr($this->pg,$repls);
	}
}
?>
